package com.foreknow.service.Impl;

import com.foreknow.dao.FoodDao;
import com.foreknow.dao.impl.FoodDaoImpl;
import com.foreknow.po.Business;
import com.foreknow.po.Food;
import com.foreknow.service.FoodService;
import com.foreknow.util.DBUtil;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

public class FoodServiceImpl implements FoodService {

    @Override
    public List<Food> getBusinessById(int businessId) {
        FoodDao foodDao = new FoodDaoImpl();
        List<Food> list = new ArrayList<>();
        try {
            list = foodDao.getBusinessById(businessId);
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }finally {
            DBUtil.close();
        }
        return list;
    }


    public static void main(String[] args) {
        FoodService service = new FoodServiceImpl();
        List<Food> list = service.getBusinessById(10001);
        for (Food f:list){
            System.out.println(f.getFoodName());
        }
    }

}
